/**
 * @Author wywinstonwy
 * @Date 2022/1/10 3:55 下午
 * @Description:
 */

import 'package:demo202112/MyNaviPage/my_one_page.dart';
import 'package:demo202112/MyNaviPage/my_two_page.dart';
import 'package:demo202112/utils/common_appbar.dart';
import "package:flutter/material.dart";

class MyNavigator extends StatefulWidget {
  const MyNavigator({Key? key}) : super(key: key);

  @override
  _MyNavigatorState createState() => _MyNavigatorState();
}

class _MyNavigatorState extends State<MyNavigator> {
  @override
  Widget build(BuildContext context) {
    return  Center(
      child: buildNavigator,
    );
  }
  Navigator get buildNavigator{
    return Navigator(
      initialRoute: '/',
      onGenerateRoute: (RouteSettings settings) {
        WidgetBuilder builder;
        switch(settings.name){
          case'home':
            builder=(context)=>OnePage();
            break;
          case 'user':
            builder=(context)=>TwoPage();
            break;
          default:
            builder=(context)=>OnePage();
            break;
        }
        return MaterialPageRoute(builder: builder, settings: settings);
      },
    );
  }
}
